<template>
  <el-descriptions
      :column="1"
      border
      class="infoTable"
      title="基本信息"
  >

    <el-descriptions-item>
      <template #label>
        <span class="label">申请编号</span>
      </template>
      {{applyItem.applyId}}
    </el-descriptions-item>
    
    <el-descriptions-item>
      <template #label>
        <span class="label">申请类型</span>
      </template>
      {{typeString}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">日期</span>
      </template>
      {{applyItem.applyDate}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">学者编号</span>
      </template>
      <el-link :href="authorUrl" target="_blank">{{applyItem.authorId}}</el-link>

    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">学者姓名</span>
      </template>
      <el-link :href="authorUrl" target="_blank">{{applyItem.authorName}}</el-link>

    </el-descriptions-item>


    <el-descriptions-item>
      <template #label>
        <span class="label">备注说明</span>
      </template>
      {{applyItem.other}}
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span class="label">审核状态</span>
      </template>
      <el-tag type="info" v-if="applyItem.isPermitted===null">待审核</el-tag>
      <el-tag type="success" v-else-if="applyItem.isPermitted===true">申请已通过审核</el-tag>
      <el-tag type="danger" v-else-if="applyItem.isPermitted==false">申请未通过审核</el-tag>
    </el-descriptions-item>

    <el-descriptions-item v-if="applyItem.isPermitted==false">
      <template #label>
        <span class="label">理由</span>
      </template>
      {{applyItem.reject}}
    </el-descriptions-item>

  </el-descriptions>

  <div style="margin-bottom: 10px"></div>
  <el-descriptions
      :column="1"
      border
      class="infoTable"
      title="文献信息"
  >

    <el-descriptions-item>
      <template #label>
        <span class="label">文献编号</span>
      </template>
      <el-link :href="paperUrl(applyItem.paperId)" target="_blank">
        <span class="link">{{applyItem.paperId}}</span>
      </el-link>

    </el-descriptions-item>
    
    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.doi,applyItem.newPaper.doi)}">doi</span>
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{applyItem.oldPaper.doi}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{applyItem.newPaper.doi}}</div>
      </div>
      
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.docType,applyItem.newPaper.docType)}">文献类型</span>
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{docType(applyItem.oldPaper.docType)}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{docType(applyItem.newPaper.docType)}}</div>
      </div>
    </el-descriptions-item>

    
      <el-descriptions-item>
        <template #label>
          <span :class="{label: true,change: isEq(applyItem.oldPaper.journal,applyItem.newPaper.journal)}">期刊名称</span>
        </template>
        <div class="old">
          <div class="title">[旧值]</div>
          <div>{{applyItem.oldPaper.journal}}</div>
        </div>
        <el-divider></el-divider>
        <div class="new">
          <div class="title">[新值]</div>
          <div>{{applyItem.newPaper.journal}}</div>
        </div>
        
      </el-descriptions-item>
    

    
      <el-descriptions-item>
        <template #label>
          <span :class="{label: true,change: isEq(applyItem.oldPaper.conferenceSeries,applyItem.newPaper.conferenceSeries)}">会议录名称</span>
          
        </template>
        <div class="old">
          <div class="title">[旧值]</div>
          <div>{{applyItem.oldPaper.conferenceSeries}}</div>
        </div>
        <el-divider></el-divider>
        <div class="new">
          <div class="title">[新值]</div>
          <div>{{applyItem.newPaper.conferenceSeries}}</div>
        </div>
        
      </el-descriptions-item>
    
      <el-descriptions-item>
        <template #label>
          <span :class="{label: true,change: isEq(applyItem.oldPaper.conferenceInstance,applyItem.newPaper.conferenceInstance)}">会议名称</span>
          
        </template>
        <div class="old">
          <div class="title">[旧值]</div>
          <div>{{applyItem.oldPaper.conferenceInstance}}</div>
        </div>
        <el-divider></el-divider>
        <div class="new">
          <div class="title">[新值]</div>
          <div>{{applyItem.newPaper.conferenceInstance}}</div>
        </div>
        
      </el-descriptions-item>
    


    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.title,applyItem.newPaper.title)}">文献标题</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{applyItem.oldPaper.title}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{applyItem.newPaper.title}}</div>
      </div>
      
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.abstract_,applyItem.newPaper.abstract_)}">文献摘要</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{applyItem.oldPaper.abstract_}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{applyItem.newPaper.abstract_}}</div>
      </div>
      
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.date,applyItem.newPaper.date)}">发表日期</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{applyItem.oldPaper.date}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{applyItem.newPaper.date}}</div>
      </div>
      
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.volume,applyItem.newPaper.volume)}">卷/册</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{applyItem.oldPaper.volume}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{applyItem.newPaper.volume}}</div>
      </div>
      
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.firstPage,applyItem.newPaper.firstPage)&&isEq(applyItem.oldPaper.lastPage,applyItem.newPaper.lastPage)}">起止页码</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>{{applyItem.oldPaper.firstPage}}——{{applyItem.oldPaper.lastPage}}</div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>{{applyItem.newPaper.firstPage}}——{{applyItem.newPaper.lastPage}}</div>
      </div>
      
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.authors.map(value=>{
          return value.authorId.toString()+value.authorSequence.toString();
        }).join('@'),applyItem.newPaper.authors.map(value=>{
          return value.authorId.toString()+value.authorSequence.toString();
        }).join('@'))}">作者</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>
          <span v-for="item in applyItem.oldPaper.authors">
            <el-link :href="authorUrl(item.authorId)" target="_blank">
              <span class="link">{{item.authorSequence+"—"+item.name}},&nbsp;</span>
            </el-link>
          </span>
        </div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>
          <span v-for="item in applyItem.newPaper.authors">
            <el-link :href="authorUrl(item.authorId)" target="_blank">
              <span class="link">{{item.authorSequence+"—"+item.name}},&nbsp;</span>
            </el-link>
          </span>
        </div>
      </div>
    </el-descriptions-item>

    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.fields.join('@'),applyItem.newPaper.fields.join('@'))}">学科领域</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>
          <span v-for="item in applyItem.oldPaper.fields">
            {{item}},&nbsp;
          </span>
        </div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>
          <span v-for="item in applyItem.newPaper.fields">
            {{item}},&nbsp;
          </span>
        </div>
      </div>
      
    </el-descriptions-item>
    
    
    <el-descriptions-item>
      <template #label>
        <span :class="{label: true,change: isEq(applyItem.oldPaper.references.map(value=>{
          return value.paperId;
        }).join('@'),applyItem.newPaper.references.map(value=>{
          return value.paperId;
        }).join('@'))}">参考文献</span>
        
      </template>
      <div class="old">
        <div class="title">[旧值]</div>
        <div>
          <div v-for="(item,index) in applyItem.oldPaper.references" style="margin-bottom: 5px">
            <el-link :href="paperUrl(item.paperId)" target="_blank">
              <span class="link">[{{index+1}}]{{item.title}}</span>
            </el-link>
          </div>
        </div>
      </div>
      <el-divider></el-divider>
      <div class="new">
        <div class="title">[新值]</div>
        <div>
          <div v-for="(item,index) in applyItem.newPaper.references" style="margin-bottom: 5px">
            <el-link :href="paperUrl(item.paperId)" target="_blank">
              <span class="link">[{{index+1}}]{{item.title}}</span>
            </el-link>
          </div>
        </div>
      </div>
      
    </el-descriptions-item>

  </el-descriptions>
</template>

<script>
export default {
  name: "UpdateApply",
  props:['applyItem'],
  data(){
    return{

    }
  },
  methods:{
    isEq(s1,s2){
      return s1!==s2;
    },
    authorUrl(authorId){
      return `/portal?authorId=${authorId}`
    },
    paperUrl(paperId){
      return `/detail?paperId=${paperId}`
    },
    docType(docType){
      if(docType===1){
        return "期刊文献"
      }else if(docType===2){
        return "会议文献"
      }
    }

  },
  computed:{
    typeString(){
      switch (this.applyItem.type){
        case "claim":
          return "认领门户申请";
        case "add":
          return "上传文献申请";
        case "update":
          return "更新文献申请";
        case "delete":
          return "删除文献申请";
      }
    }
  }
}
</script>

<style scoped>
.title{
  font-weight: bold;
}
.change{
  color: red;
}
.infoTable{
  font-size: 16px;
  word-break: break-word;
}
.link{
  font-size: 16px;
}
.label{
  word-break: keep-all;
}
</style>